using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class ToggleButton : MonoBehaviour
{
	public bool isEnable;

	private bool _isActive;

	public UIButton buttonOn;

	public UIButton buttonOff;

	public List<EventDelegate> onActivate = new List<EventDelegate>();

	public List<EventDelegate> onDeactivate = new List<EventDelegate>();

	public bool IsActive
	{
		get
		{
			return _isActive;
		}
		set
		{
			_isActive = value;
			if (!(buttonOn == null) && !(buttonOff == null))
			{
				_isActive = value;
				isEnable = _isActive;
				buttonOn.gameObject.SetActive(_isActive);
				buttonOff.gameObject.SetActive(!_isActive);
			}
		}
	}

	private void OnPress(bool pressed)
	{
		if (pressed)
		{
			EventDelegate.Execute(onActivate);
		}
		else
		{
			EventDelegate.Execute(onDeactivate);
		}
	}

	private void SetActiveButton(bool val)
	{
		IsActive = val;
		if (Application.isPlaying)
		{
			OnPress(_isActive);
		}
	}

	public void Activate()
	{
		SetActiveButton(true);
	}

	public void Deactivate()
	{
		SetActiveButton(false);
	}
}
